package com.ie.controller;

import com.ie.common.http.Result;
import com.ie.common.http.ResultCodeEnum;
import com.ie.entity.Losspets;
import com.ie.entity.dto.LosspetsDto;
import com.ie.service.LosspetsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/losspets")
public class LosspetsController
{
    @Autowired
    private LosspetsService losspetsService;

    //查询丢失宠物
    @RequestMapping("/all")
    public List<Losspets> getAllLosspets()
    {
        return losspetsService.getAllLosspets();
    }
    //删除
    @RequestMapping("/delete")
    public boolean deleteLosspets(@RequestParam("id") String id)
    {
        return losspetsService.deleteLosspets(id);
    }

    /**
     * 获取宠物丢失信息
     */
    @GetMapping("/lost")
    public Result getLostPet(
            @RequestParam("name") String name,
            @RequestParam("type") String type,
            @RequestParam("city") String city
    ) {
        List lossPets = losspetsService.selectList(name, type, city);
        return Result.build(lossPets, ResultCodeEnum.SUCCESS);
    }

    /**
     * 新增
     */
    @PostMapping("/addLostPet")
    public Result addLostPet(@RequestBody LosspetsDto losspetsDto) {
        losspetsService.addLosspets(losspetsDto);
        return null;
    }
}
